<!--OEM代理——点数配置-->
<template>
  <div class="ele-body">
    <el-card>
      <div class="set-hint">
        <span>说明</span><br>
        <!--        数字人视频：目前阿里云扣费标准为每秒0.165元，点数请自行控制，不得低于成本<br>
        剪辑视频：剪辑视频发布才会扣除<br>-->
        数字人视频：请设置数字人创作每秒扣点数（阿里云成本为10元1分钟，约0.165一秒）<br>
        剪辑视频：请输入创作中心混剪次数扣点数<br>
        <!--          删除视频：D音cookie发布才会扣除<br>-->
        <!--发布视频：指使用中转接口发布视频到dou音需要扣除商户的点数，可保留两位小数点<br>
        视频置顶： 指使用中转接口将已发布到dou音的视频进行置顶需要扣除商户的点数，可保留两位小数点<br>
        删除已发布视频： 指使用中转接口删除已发布到dou音的视频需要扣除商户的点数，可保留两位小数点<br>
        回复评论：指使用中转接口回复视频下的评论需要扣除商户的点数，可保留两位小数点<br>
        橱窗挂载：指使用中转接口创建矩阵发布任务时选择挂载橱窗的话进行扣点，可保留两位小数点-->
      </div>
      <!--<el-tabs v-model="active" class="user-info-tabs">
        <el-tab-pane label="点数配置" name="info">-->
      <el-form
        :show-message="false"
        ref="form"
        :model="form"
        :rules="rules"
        label-position="right"
        label-width="120px"
        @keyup.enter.native="submit"
        @submit.native.prevent
      >
        <div class="content">
          <!--          <el-form-item label="选择商户" prop="merchantId">-->
          <!--            <el-select-->
          <!--              v-model="form.merchantId"-->
          <!--              placeholder="请选择商户"-->
          <!--              class="ele-fluid"-->
          <!--              clearable-->
          <!--              @clear="see()"-->
          <!--            >-->
          <!--              <el-option-->
          <!--                v-for="item in list"-->
          <!--                :key="item.id"-->
          <!--                :label="item.merchantName"-->
          <!--                :value="item.id">-->
          <!--              </el-option>-->
          <!--            </el-select>-->
          <!--          </el-form-item>-->

          <el-form-item label="数字人视频" prop="windowMounting">
            <el-input
              :maxLength="8"
              oninput="value=value.replace(/[^0-9]/g,'')"
              v-model="form.windowMounting"
              placeholder="请输入数字人视频消耗点数"
              clearable
            />
          </el-form-item>
          <el-form-item label="剪辑视频" prop="releaseVideos">
            <el-input
              :maxLength="8"
              oninput="value=value.replace(/[^0-9]/g,'')"
              v-model="form.releaseVideos"
              placeholder="请输入剪辑视频消耗点数"
              clearable
            />
          </el-form-item>
          <!-- <el-form-item label="视频置顶" prop="videoOverhead">
             <el-input
               :maxLength="8"
               oninput="value=value.replace(/[^0-9]/g,'')"
               v-model="form.videoOverhead"
               placeholder="请输入视频置顶消耗点数"
               clearable
             />
           </el-form-item>
           <el-form-item label="删除已发布视频" prop="deletePostedVideo">
             <el-input
               :maxLength="8"
               oninput="value=value.replace(/[^0-9]/g,'')"
               v-model="form.deletePostedVideo"
               placeholder="请输入删除已发布视频消耗点数"
               clearable
             />
           </el-form-item>-->
          <!--<el-form-item label="回复评论" prop="replyComment">
            <el-input
               :maxLength="8"
               oninput="value=value.replace(/[^0-9]/g,'')"
              v-model="form.replyComment"
              placeholder="请输入回复评论点数"
              clearable
            />
          </el-form-item>
          <el-form-item label="橱窗挂载" prop="windowMounting">
            <el-input
               :maxLength="8"
               oninput="value=value.replace(/[^0-9]/g,'')"
              v-model="form.windowMounting"
              placeholder="请输入橱窗挂载点数"
              clearable
            />
          </el-form-item>-->

        </div>
        <div class="btn-cls">
          <el-button type="primary" @click="save()" :loading="loading">
            确认
          </el-button>
          <el-button @click="resetting()">
            重置
          </el-button>
        </div>
      </el-form>
      <!--</el-tab-pane>
          </el-tabs>-->
    </el-card>
  </div>
</template>

<script>
  import {getMerchant,pointAdd,pageList} from '@/api/agent/pointAllocation'
  import {ossUpdate, registerAssetsMedia} from "@/api/creatCenter/material";
  export default {
    name: "index",
    data(){
      return{
        // tab页选中
        active: 'info',
        loading:false,
        // 商户list
        list:[],
        form:{
          oemId:this.$store.state.user.info.oemId
        },
        rules: {
          /*merchantId: [
            {
              required: true,
              message: '请选择商户',
              trigger: 'blur'
            }
          ],*/
          releaseVideos: [
            {
              required: true,
              message: '请输入发布视频消耗点数',
              trigger: 'blur'
            }
          ],
          videoOverhead: [
            {
              required: true,
              message: '请输入视频置顶消耗点数',
              trigger: 'blur'
            }
          ],
          deletePostedVideo: [
            {
              required: true,
              message: '请输入删除已发布视频消耗点数',
              trigger: 'blur'
            }
          ],
          replyComment: [
            {
              required: true,
              message: '请输入回复评论点数',
              trigger: 'blur'
            }
          ],
          windowMounting: [
            {
              required: true,
              message: '请输入生成视频消耗点数',
              trigger: 'blur'
            }
          ],
        }
      }
    },
    created(){
      this.init()
    },
    methods:{
      init(){
        // 查询点数
        pageList({
          oemId:this.$store.state.user.info.oemId
        })
          .then((data) => {
            console.log("data=====",data)
            if(data!=null){
              this.form=data
            }
          })
          .catch((e) => {
            this.$message.error(e);
          });

        /*// 查询商户
        getMerchant({})
          .then((data) => {
            console.log("data=====",data)
            this.list=data.data
          })
          .catch((e) => {
            this.$message.error(e);
          });*/
      },
      save(){
        console.log("this.form",this.form)
        this.$refs.form.validate((valid, obj) => {
          console.log('valid',valid,'obj',obj)
          for(let i in obj){
            console.log("i",i)
            console.log("obj=========",obj[i][0].message)
            this.hint=obj[i][0].message
            break
          }
          console.log('this.hint',this.hint)
          if (valid) {
            this.loading=true
            console.log("成功")
            pointAdd(this.form)
              .then((data) => {
                this.$message.success('保存成功！');
                this.init()
                // this.resetting()
                this.loading=false
              })
              .catch((e) => {
                this.$message.error(e);
                this.loading=false
              });
          } else {
            console.log("进入非空提示",valid,'22',this.form)
            this.$message.error(this.hint)
            return false;
          }
        });
      },
      resetting(){
        this.$refs.form.resetFields()
      }
    }
  }
</script>

<style scoped lang="less">
  .set-hint{
    span{
      font-size: 16px;
      line-height: 24px;
    }
    border: 1px solid;
    margin: 12px 0 16px;
    padding: 14px 20px;
    background: #E6F7FF;
    border-radius: 5px;
    line-height: 28px;
    color: #379FFF;
  }
  .content{
    padding: 12px 11px 25px;
  }
  .btn-cls{
    margin-left: 130px;
    margin-bottom: 20px;
  }
</style>
